
var vm = new Vue({
    el : "#xbkSjList",
    data : {
    },
    init:function(){
        var _self = this;
        layui.use(['layer'], function(){
            layer = layui.layer;
        });
    },
    methods: {
        getWarhourseCode: function(event){
            var _self = this;
            var code = document.getElementById("sjCode").value;   //作业工单RFID

            if (event && (event.keyCode != 13 || !(code && code.length > 0))) {
                return;
            }
            _self.changeRfid(_self,code);
        },
        changeRfid: function(_self, code){

            var data ={
                code : code
            };
            _self.$nextTick(function() {
                _self.$http.post(host +"xbkSjList/selectXbkSjListByCode",data,{emulateJSON: true}).then(function(res){
                    if(res.ok){
                        _self.xbkSjListData = res.body.xbkSjListByCode;
                        _self.PlanList = res.body.PlanList;
                        _self.message = res.body.message;
                        if(_self.xbkSjListData == "false"){
                            _self.vueAlert("此RFID不存在！");
                            document.getElementById("wlCode").innerText="";

                            document.getElementById("inTime").innerText="";

                            $("#qtys").val("");
                            return;
                        }
                        document.getElementById("wlCode").innerText=_self.PlanList[0].WLVALUE +"-"+_self.PlanList[0].WLNAME ;

                        document.getElementById("inTime").innerText=_self.PlanList[0].TIMES;

                        $("#qtys").val(1);
                    }
                });
            });
        },
        saveRfidLists: function(){
            var _self =this;
            var code = document.getElementById("sjCode").value;   //作业工单RFID
            var qtys = document.getElementById("qtys").value;   //上架数量

            if(code == null || code == ""){
                this.vueAlert("RFID不能为空！");
                return;
            }

            if(qtys == null || qtys == ""){
                this.vueAlert("上架数量不能为空！");
                return;
            }
            var data ={
                code : code,
                qtys : qtys
            };
            _self.$nextTick(function() {
                _self.$http.post(host +"xbkSjList/saveXbkSjListByCode",data,{emulateJSON: true}).then(function(res){
                    if(res.ok){
                        _self.xbkSjListData = res.body.xbkSjListByCode;
                        _self.message = res.body.message;
                        _self.result = res.body.result;
                        if(_self.xbkSjListData == "false"){
                            _self.vueAlert("此RFID不存在！");
                            return;
                        }else if(_self.result  == "false"){
                            _self.vueAlert("上架失败！");
                            return;
                        }else{
                            _self.vueAlert("上架成功！");
                            window.setTimeout(function() {
                                window.location.reload();
                            }, 1000);
                            return;
                        }
                    }
                });
            });
        },
        reset:function(data){
            window.location.reload();
        },
        vueAlert:function(msg){
            layui.use(['form'], function(){
                var layer = layui.layer;
                layer.msg(msg,{icon:6,time:2000});
            });
        }//,
        /*renderTable: function(_self,data){
            layui.use(['form','table','laydate'], function(){
                _self.table = layui.table;
                var form = layui.form;

                _self.table.render({
                    elem: '#xbkSjListTable',
                    width: 'full-20',
                    height: 'full-150',
                    cols: [[ //标题栏
                        { field: 'OPT_CODE', title: '工单号',width: 200},
                        {field: 'PRODUCTNAME', title: '型体',width: 200, align:'center' },
                        {field: 'OPT_MODE', title: '状态', minWidth: 80,align:'center'},
                        {field: 'UPDATED', title: '上架时间', minWidth: 160,align:'center',templet: "<div>{{layui.util.toDateString(d.EXE_DATE_FROM, 'yyyy-MM-dd HH:mm:ss')}}</div>"},
                        {field: 'DESCRIPTION', title: '操作提示', minWidth: 160,align:'center',templet: "<div>{{layui.util.toDateString(d.EXE_DATE_TO, 'yyyy-MM-dd HH:mm:ss')}}</div>"}
                    ]],
                    data:data,
                    page: true, //是否显示分页
                    limits: [10, 20, 50],
                    limit: 15 //每页默认显示的数量
                });
            });
        }*/
    }
});